package com.kfm.servlet.day02;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/dispatcher")
public class DispatcherServlet extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("DispatcherServlet.doGet");

        req.setAttribute("name", "李四");

        // 请求转发
//        RequestDispatcher requestDispatcher = req.getRequestDispatcher("/dispatcher1");
//        requestDispatcher.forward(req, resp)
        req.getRequestDispatcher("/dispatcher1").forward(req, resp);
    }
}
